﻿@{
        var action = UrlData[0].ToLower();
       
         
        //check admin type
        int reportType = Convert.ToInt32(Request["adminType"]);
        string adminTitle=string.Empty;
        string param = string.Empty;
        string[] cols=null;
        switch(reportType){
            case 1:
                adminTitle = "User Profiles";
                cols = new []{"UserId","Email"};
       
                break;
            case 2:
                adminTitle = "Roles";
                cols = new []{"RoleId","RoleName"};
                break;
            case 3:
                adminTitle="User Roles";
                cols = new []{"RoleId","RoleName"};
                param = Request["user"];
                break;
            case 4:
                break;
                
               
                
        }
        
        
        //var ccList = CashCardManager.ExtractData(c,action);
        var reportData =  AccountManager.GetData(param,reportType);
        var grid = new WebGrid(reportData,canSort:false,columnNames:cols,ajaxUpdateContainerId: "grid",ajaxUpdateCallback: "addCheck");
        Page.ReportData=reportData;
}
<script>
    $(function(){
        $("#genXLS").click(function(){
            genXLS();
        });
        
        $("#genPDF").click(function(){
            genPDF();
        });
    });
    
function genXLS(){
       
       $("#report").attr("action", "/Reports/GenerateExcel/" + @reportType);
       $("#report").submit();
}   

function genPDF(){
       $("#report").attr("action", "/Reports/GeneratePDF/" + @reportType);
       $("#report").submit();
    
}


 function addCheck(){
            var $chk = $('<input/>').attr({ type: 'checkbox', name:'chkAll', id: 'chkAll', title: "Select All"});
            $('th:last').append($chk);
            $('#chkAll').click(function(){
                $(':checkbox').prop('checked', $(this).is(':checked') ? true : false );
                $("#download").prop('disabled',$(this).is(':checked') ? false : true );
                $("#print2pdf").prop('disabled',$(this).is(':checked') ? false : true );
            });
            
             $(':checkbox').not('#chkAll').click(function(){
               testCheck();
        });
            
        }
        
     function testCheck() {
        if($(':checkbox').not('#chkAll').filter(':not(:checked)').length === 0){
            $('#chkAll').prop('checked', true);
        } else {
            $('#chkAll').prop('checked', false);
            
        }
        
        if($(':checkbox').filter(':not(:checked)').length === 0){
             $("#download").prop('disabled',true);
             $("#print2pdf").prop('disabled',true);
            
        }else{
             $("#download").prop('disabled',false);
             $("#print2pdf").prop('disabled',false);
            
        }
    }
</script>
 <fieldset>           
 <legend>@adminTitle</legend>
    <form method="post"  id="report">
   
   
     
        
    <div id="grid" class="page">
      @grid.GetHtml(
               tableStyle:"ui-widget ui-widget-content",
               alternatingRowStyle:"alternate",
               headerStyle:"ui-widget-header"
              )
    </div>
        <div id="buttons" align="right">
          
            
        </div>
        </form>
      </fieldset>